"use strict";
const { Model } = require("sequelize");
const { IdGenerator } = require("../utils/idGenerator");
module.exports = (sequelize, DataTypes) => {
class <%= modelName %> extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// define association here
}
}

<%= modelName %>.init({
id: {
type: DataTypes.INTEGER.UNSIGNED, // 无符号整数类型
allowNull: false,
primaryKey: true,
defaultValue: function () {
return IdGenerator.getNextID(); // 使用封装的ID生成方法
},
},
<% for(var i = 0; i < fields.length; i++) { if(fields[i].name !== 'id'){ %>
    <%= fields[i].name %>: DataTypes.<%= fields[i].type.toUpperCase() %>, // <%= fields[i].title %>
<% }
} %>
createdAt: {
allowNull: false,
type: DataTypes.DATE,
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE,
},
},
{
sequelize,
modelName: "<%= modelName %>",
},
);
return <%= modelName %>;
};
